]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
panel: Update corners' nearest button on session mode change
authorRui Matos <tiagomatos@gmail.com>
Thu, 13 Dec 2012 21:35:00 +0000 (22:35 +0100)
committerRui Matos <tiagomatos@gmail.com>
Fri, 4 Jan 2013 13:35:53 +0000 (13:35 +0000)
With panel buttons changing dynamically on session mode changes we can
no longer rely on a corner's respective box style-changed signal to
find the nearest button.

Instead, make the panel take care of telling the corners to look for a
new button when buttons are changed.

https://bugzilla.gnome.org/show_bug.cgi?id=690180

js/ui/panel.js

index 3845dd0bbd1a31c1c6da22b85fdf67ad106d27de..3618c7814e860c32f5613e773edb13eb3ac98977 100644 (file)
@@ -751,12 +751,9 @@ const ActivitiesButton = new Lang.Class({
 const PanelCorner = new Lang.Class({
     Name: 'PanelCorner',
 
-    _init: function(box, side) {
+    _init: function(side) {
         this._side = side;
 
-        this._box = box;
-        this._box.connect('style-changed', Lang.bind(this, this._boxStyleChanged));
-
         this.actor = new St.DrawingArea({ style_class: 'panel-corner' });
         this.actor.connect('style-changed', Lang.bind(this, this._styleChanged));
         this.actor.connect('repaint', Lang.bind(this, this._repaint));
@@ -812,12 +809,12 @@ const PanelCorner = new Lang.Class({
         return children[index];
     },
 
-    _boxStyleChanged: function() {
+    setStyleParent: function(box) {
         let side = this._side;
 
-        let rtlAwareContainer = this._box instanceof St.BoxLayout;
+        let rtlAwareContainer = box instanceof St.BoxLayout;
         if (rtlAwareContainer &&
-            this._box.get_text_direction() == Clutter.TextDirection.RTL) {
+            box.get_text_direction() == Clutter.TextDirection.RTL) {
             if (this._side == St.Side.LEFT)
                 side = St.Side.RIGHT;
             else if (this._side == St.Side.RIGHT)
@@ -826,9 +823,9 @@ const PanelCorner = new Lang.Class({
 
         let button;
         if (side == St.Side.LEFT)
-            button = this._findLeftmostButton(this._box);
+            button = this._findLeftmostButton(box);
         else if (side == St.Side.RIGHT)
-            button = this._findRightmostButton(this._box);
+            button = this._findRightmostButton(box);
 
         if (button) {
             if (this._button && this._buttonStyleChangedSignalId) {
@@ -963,17 +960,10 @@ const Panel = new Lang.Class({
         this._rightBox = new St.BoxLayout({ name: 'panelRight' });
         this.actor.add_actor(this._rightBox);
 
-        if (this.actor.get_text_direction() == Clutter.TextDirection.RTL)
-            this._leftCorner = new PanelCorner(this._rightBox, St.Side.LEFT);
-        else
-            this._leftCorner = new PanelCorner(this._leftBox, St.Side.LEFT);
-
+        this._leftCorner = new PanelCorner(St.Side.LEFT);
         this.actor.add_actor(this._leftCorner.actor);
 
-        if (this.actor.get_text_direction() == Clutter.TextDirection.RTL)
-            this._rightCorner = new PanelCorner(this._leftBox, St.Side.RIGHT);
-        else
-            this._rightCorner = new PanelCorner(this._rightBox, St.Side.RIGHT);
+        this._rightCorner = new PanelCorner(St.Side.RIGHT);
         this.actor.add_actor(this._rightCorner.actor);
 
         this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
@@ -1146,6 +1136,14 @@ const Panel = new Lang.Class({
         this._sessionStyle = Main.sessionMode.panelStyle;
         if (this._sessionStyle)
             this._addStyleClassName(this._sessionStyle);
+
+        if (this.actor.get_text_direction() == Clutter.TextDirection.RTL) {
+            this._leftCorner.setStyleParent(this._rightBox);
+            this._rightCorner.setStyleParent(this._leftBox);
+        } else {
+            this._leftCorner.setStyleParent(this._leftBox);
+            this._rightCorner.setStyleParent(this._rightBox);
+        }
     },
 
     _hideIndicators: function() {